package com.jisucloud.clawler.regagent.service.impl.borrow;

import lombok.extern.slf4j.Slf4j;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.Response;

import com.jisucloud.clawler.regagent.interfaces.PapaSpider;
import com.jisucloud.clawler.regagent.interfaces.PapaSpiderConfig;

import java.util.Map;

@Slf4j
@PapaSpiderConfig(
		home = "newup.com", 
		message = "新升贷(www.newup.net.cn)是专注于汽车抵押借贷服务的互联网金融P2P网贷平台,新升贷致力于打造一个专业、规范、安全、高效、诚信的汽车抵押网络借贷中介平台,通过..。", 
		platform = "newup", 
		platformName = "新升贷", 
		tags = { "P2P", "消费分期" ,"车贷", "借贷" }, 
		testTelephones = { "15985268904", "18212345678" })
public class XinShengDaiSpider extends PapaSpider {

	
	
	public boolean checkTelephone(String account) {
		try {
			String url = "https://www.newup.net.cn/index/register/checkPhone";
			FormBody formBody = new FormBody
	                .Builder()
	                .add("phone", account)
	                .build();
			Request request = new Request.Builder().url(url)
					.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0")
					.addHeader("Host", "www.newup.net.cn")
					.addHeader("Referer", "https://www.newup.net.cn/index/register/page")
					.post(formBody)
					.build();
			Response response = okHttpClient.newCall(request).execute();
			if (response.body().string().contains("手机号存在")) {
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean checkEmail(String account) {
		return false;
	}

	@Override
	public Map<String, String> getFields() {
		return null;
	}

}
